/////precompiled////////
#include "precompiled.h"
////////////////////////


#include "prs_FrmParaEdit.h"
using namespace prs;

// TNodeFrmParaEdit ///////////////////////////////////////////////////////////

//
frm::control::TParaEdit *TNodeFrmParaEdit::BuildControl(
  frm::control::TPanel *ParentControl
)
{
  frm::control::TParaEdit *P = Control.GetValue();

  if (!P || &P->GetWindow() != &ParentControl->GetWindow()) {
    delete P; 
    P = new frm::control::TParaEdit(ParentControl->GetWindow());
    Control.SetValue(P);
    ParentControl->AddChildLast(P,false);

    P->SetEnFormatting(true);  

    Geometry.Value.UnionWidthTo (P->GetGeometry());
    Geometry.Value.UnionHeightTo(P->GetGeometry());
    Geometry.Value.UnionHAlignTo(P->GetGeometry());
    Geometry.Value.UnionBorderTo(P->GetGeometry());
  }
  
  return P;
}

// TRuleFrmParaEdit ///////////////////////////////////////////////////////////

//
TRuleFrmParaEdit::TRuleFrmParaEdit(
  snt::text::TContext &Context,
  svl::TVariant &VParentNode,
  TRuleFrmChildrenBase &RChildren,
  TRuleSetNodeIdOptionally &RSetNodeIdOptionally,
  TRuleFrmGeom &RFrmGeom,
  TRuleSetStyle &RStyle
) 
:vParentNode(VParentNode)
,rGeometry(RFrmGeom)
{
  snt::text::TSequence T(Context);
  snt::text::TKeyword K(Context);
  snt::TFVoid F;
  TFuncNewNodeIntoAttrOldChildren FNewNode;
  snt::TReturn Return;

  this->Name(GetClassName()).Local(vParentNode)
  | K.New("paraEdit") & FNewNode.New(vParentNode,TNodeFrmParaEdit()) 
    & RSetNodeIdOptionally.New() & RAttr.New() 
    & Return.New()
  ;
  
  RAttr
  | T.New("(") 
    & RAttr1.New() & RChildren.New() 
    & T.New(")") & Return.New()
  | Return.New()
  ;

  RAttr1
  | AAttr1.New()
  ;
  AAttr1
  | RStyle.New() & AAttr1.New()
  | F.New(this,&TRuleFrmParaEdit::FSetGeometry) & RFrmGeom.New() & AAttr1.New()
  | Return.New()
  ;
}
